package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.mapper.EmpExprMapper;
import com.itheima.mapper.EmpMapper;
import com.itheima.mapper.ReportMapper;
import com.itheima.pojo.*;
import com.itheima.service.EmpLogService;
import com.itheima.service.EmpService;
import com.itheima.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    private ReportMapper reportMapper;


    @Override
    public List<Map> employeeGenderStats() {
        return reportMapper.employeeGenderStats1();
    }

    @Override
    public EmpJobData employeePositionCount() {

        List<Map<String, Object>> list = reportMapper.employeePositionCount();
        List<Object> jobList = list.stream().map(dataMap -> dataMap.get("jobName")).toList();
        List<Object> dataList = list.stream().map(dataMap -> dataMap.get("nums")).toList();
        return new EmpJobData(jobList, dataList);
    }

    @Override
    public List<Map> studentEducationStats() {
        return reportMapper.studentEducationStats();
    }

    @Override
    public ClazzNumberData classStudentCount() {
        List<Map<String, Object>> list = reportMapper.classStudentCount();
        List<String> clazzList = list.stream().map(dataMap -> (String) dataMap.get("clazzName")).toList();
        List<Integer> dataList = list.stream().map(dataMap -> ((Long) dataMap.get("nums")).intValue()).toList();
        return new ClazzNumberData(clazzList, dataList);
    }
}